package cn.aiweiyi.qingjing.coupon.distribution.feign;

import cn.aiweiyi.qingjing.coupon.comm.exception.CouponException;
import cn.aiweiyi.qingjing.coupon.comm.vo.CommonResponse;
import cn.aiweiyi.qingjing.coupon.comm.vo.SettlementInfo;
import cn.aiweiyi.qingjing.coupon.distribution.feign.hystrix.SettlementClientHystrix;
import cn.aiweiyi.qingjing.coupon.distribution.feign.hystrix.TemplateClientHystrix;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 优惠券结算微服务的feign调用接口
 */
@FeignClient(value = "eureka-client-coupon-settlement",
        url = "http://localhost:7003/",
        fallback = SettlementClientHystrix.class)//指定一个兜底(降级)策略实现类
public interface SettlementClient {
    /**
     * 优惠券规则计算
     *
     * @param settlement
     * @return
     * @throws CouponException
     */
    @RequestMapping(value = "/coupon-settlement/settlement/compute",
            method = RequestMethod.POST)
    CommonResponse<SettlementInfo> couputeRule(
            @RequestBody SettlementInfo settlement) throws CouponException;


}
